import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, OpenTwoRouter } from '../Common/options'

export const SecurityTrain = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        hideInSearch: true,
        options: [<AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization },
            commonTableList.tableName,
            {
                dataIndex: 'personCount',
                title: '人数',
                valueType: 'inputNumber',
                ellipsis: true,
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'duration',
                title: '时长',
                valueType: 'inputNumber',
                ellipsis: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'trainTime',
                title: '培训时间',
                valueType: 'Date',
                ellipsis: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'leaderName',
                title: '负责人',
                valueType: 'inputNumber',
                ellipsis: true,
                rules: true,
                width: 200,
            },
            commonTableList.isEnabled,
            commonTableList.sortId,
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 400,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,
                        <OpenTwoRouter
                            key="openTwo"
                            title="人员培训"
                            twoTitle="员培训明细"
                            modal="TableList"
                            OptionsEvent={OptionsEvent}
                            other={{
                                page: 'SecurityTrain',
                                Permission,
                                oneData: record,
                                header: data.columns,
                            }}
                        />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
